package com.dengyafei.service.impl;

import com.dengyafei.bean.AccountBean;
import com.dengyafei.mapper.AccountBeanMapper;
import com.dengyafei.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 邓亚非
 */
@Service
public class AccountServiceImpl implements AccountService {
    @Autowired
    AccountBeanMapper accountBeanMapper;

    @Override
    public boolean insertAccount(AccountBean accountBean) {
        int value = accountBeanMapper.insert(accountBean);
        return value > 0;
    }

    @Override
    public boolean deleteAccount(Integer id) {
        int value = accountBeanMapper.deleteByPrimaryKey(id);
        return value > 0;
    }

    @Override
    public boolean updateAccount(AccountBean accountBean) {
        int value = accountBeanMapper.updateByPrimaryKey(accountBean);
        return value > 0;
    }

    @Override
    public List<AccountBean> selectAccount(Integer id, String password) {

        List<AccountBean> accountBeans = accountBeanMapper.selectByIdAndPassWord(id, password);
        return accountBeans;
    }

    @Override
    public List<AccountBean> selectById(Integer id) {
        AccountBean accountBean = accountBeanMapper.selectByPrimaryKey(id);
        List<AccountBean> accountBeanList = new ArrayList<>();
        accountBeanList.add(accountBean);
        return accountBeanList;
    }
}